<template>
  <div>
      <el-card>
          账号：<el-input placeholder=请输入内容 v-model=user.useraccount :disabled=true></el-input>
          姓名：<el-input placeholder=请输入内容 v-model=user.userrname></el-input>
          密码：<el-input placeholder=请输入内容 v-model=user.userpassword></el-input>
          帐号状态：<el-switch v-model=newstate disabled></el-switch>

          <el-button type=primary @click="newUser()">确认更新信息</el-button>
      </el-card>
  </div>
</template>

<script>
export default {
data () {
      return {
          user: null,
          newstate:''
        
      }
    },
    created() {
        this.getUser()
    },
    methods: {

      //获取当前登录用户信息
      getUser() {
        this.getRequest('/user/info').then(resp => {
          this.user = resp
          if (resp.state=='true') {
            this.newstate=true
          }else {
            this.newstate=false
          }
          console.log(resp)
        })
      },

      //确认更新信息
      newUser () {
        this.putRequest('/updata',this.user).then(resp => {
          if (resp) {
            this.getUser()
          }
        })
      }
    }

}
</script>

<style lang=less scoped>
.el-card {
  margin-top:20px;

}
.el-input {
  width: 40%;
  margin-right: 100%;
  margin-bottom: 10px;
    min-width: 300px;
}
.el-button {
  margin-top:10px;
  margin-left: 16%;
}
</style>>
